package com.zhss.eshop.schedule.mapper;

import com.zhss.eshop.schedule.domain.model.ScheduleOrderPickingItem;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ScheduleOrderPickingItemMapper {
    int deleteByPrimaryKey(Long id);

    int insertSelective(ScheduleOrderPickingItem record);

    ScheduleOrderPickingItem selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(ScheduleOrderPickingItem record);

    /**
     * 根据订单id和订单条目id查询拣货条目
     * @param orderInfoId 订单id
     * @param orderItemId 订单条目id
     * @return
     */
    @Select("SELECT "
            + "id,"
            + "order_info_id,"
            + "order_item_id,"
            + "goods_allocation_id,"
            + "goods_sku_id,"
            + "picking_count,"
            + "gmt_create,"
            + "gmt_modified "
            + "FROM schedule_order_picking_item "
            + "WHERE order_info_id=#{orderInfoId} "
            + "AND order_item_id=#{orderItemId}")
    @Results({
            @Result(column = "id", property = "id", id = true),
            @Result(column = "order_info_id", property = "orderInfoId"),
            @Result(column = "order_item_id", property = "orderItemId"),
            @Result(column = "goods_allocation_id", property = "goodsAllocationId"),
            @Result(column = "goods_sku_id", property = "goodsSkuId"),
            @Result(column = "picking_count", property = "pickingCount"),
            @Result(column = "gmt_create", property = "gmtCreate"),
            @Result(column = "gmt_modified", property = "gmtModified")
    })
    List<ScheduleOrderPickingItem> listByOrderItemId(
            @Param("orderInfoId") Long orderInfoId,
            @Param("orderItemId") Long orderItemId);
}
